from constructors.abs import SingleServerObject, AbstractConstructor


class VanillaConstructor(AbstractConstructor):
    def __init__(self, executor: str, xms: int, xmx: int, enable_utf8: bool = True, args: list[str] = ()):
        self.args = args
        self.enable_utf8 = enable_utf8
        self.xmx = xmx
        self.xms = xms
        self.executor = executor

    def construct(self, path: str, file: str, _) -> SingleServerObject:
        args = self.args.copy()
        args.append(f'-Xms{self.xms}M')
        args.append(f'-Xmx{self.xmx}M')
        if self.enable_utf8:
            args.append('-Dfile.encoding=UTF-8')
        return SingleServerObject(self.executor, path, file, options=args)
